import superRequest from '@/utils/http/index'
import { IDataType } from '@/utils/http/types'

/** 用户登录(接口) */
export const apiLogin = async (data: any) => {
  return await superRequest.post<IDataType>({
    url: '/auth/login',
    data,
  })
}

/** 用户注册(接口) */
export const apiRegister = async (data: any) => {
  return await superRequest.post<IDataType>({
    url: '/auth/register',
    data,
  })
}

/** 获取用户信息(接口) */
export const apiGetUserInfo = async () => {
  return await superRequest.get<IDataType>({
    url: '/profile/me',
  })
}

/** 用户退出(接口) */
export const apiLogout = async () => {
  return await superRequest.get<IDataType>({
    url: '/auth/logout',
  })
}

/** 修改密码(接口) */
export const apiChangePassword = async (data: any) => {
  return await superRequest.post<IDataType>({
    url: '/profile/changePassword',
    data,
  })
}

/** 用户列表(接口) */
export const apiUserList = async (data: any) => {
  return await superRequest.post<IDataType>({
    url: '/user/list',
    data,
  })
}

/** 用户新增(接口) */
export const apiUserAdd = async (data: any) => {
  return await superRequest.post<IDataType>({
    url: '/user/add',
    data,
  })
}

/** 用户修改(接口) */
export const apiUserUpdate = async (data: any) => {
  return await superRequest.post<IDataType>({
    url: '/user/update',
    data,
  })
}

/** 用户删除(接口) */
export const apiUserDelete = async (data: any) => {
  return await superRequest.post<IDataType>({
    url: '/user/delete',
    data,
  })
}

/** 更新用户信息(接口) */
export const apiUpdateUserInfo = async (data: any) => {
  return await superRequest.post<IDataType>({
    url: '/profile/updateUser',
    data,
  })
}
